package com.gxa.autoparts.portal.service.impl;

import com.gxa.autoparts.core.pojo.Address;
import com.gxa.autoparts.core.service.impl.BaseServiceImpl;
import com.gxa.autoparts.portal.mapper.AddressManagerMapper;
import com.gxa.autoparts.portal.mapper.AddressMapper;
import com.gxa.autoparts.portal.service.AddressManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service("addressManagerService")
public class AddressManagerServiceImpl extends BaseServiceImpl<Address> implements AddressManagerService {

    @Autowired
    AddressMapper addressMapper=null;

    @Override
    public List<Address> findAddress(Long id) {
        Example example=new Example(Address.class);

        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId",id);

        return addressMapper.selectByExample(example);

    }

    @Override
    public void updateAddress(Address address) {

        addressMapper.updateByPrimaryKeySelective(address);
    }

    @Override
    public Address findOne(Long id) {

        Address address = addressMapper.selectByPrimaryKey(id);

        return address;

    }
}
